package com.xh.audit.vo.webform;

import com.mybatisflex.core.query.QueryWrapper;
import com.xh.audit.entity.WorkPlan;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

import static com.xh.audit.entity.table.WorkPlanTableDef.WORK_PLAN;


@Data
@EqualsAndHashCode(callSuper = true)
public class WorkPlanQuery extends PageParams<WorkPlan> {
    private Integer auditUnitCode;
    private String planName;
    private Integer planYear;
    private Integer editedUsercode;

    private Date editedDatetimeS;
    private Date editedDatetimeE;


    public QueryWrapper queryWrapperBuild() {
        QueryWrapper queryWrapper = QueryWrapper.create()
                .and(WORK_PLAN.PLAN_YEAR.eq(planYear))
                .and(WORK_PLAN.AUDIT_UNIT_CODE.eq(auditUnitCode))
                .and(WORK_PLAN.EDITED_USERCODE.eq(editedUsercode))
                .and(WORK_PLAN.EDITED_DATETIME.ge(editedDatetimeS))
                .and(WORK_PLAN.EDITED_DATETIME.le(editedDatetimeE))
                .and(WORK_PLAN.PLAN_NAME.likeLeft(planName));
        return queryWrapper;
    }
}
